//
// Created by Semir on 2020/6/7.
//

#include <iostream>
#include <string>

using namespace std;

void Reverse(string& str, int begin, int end) {
    if (begin >= end) {
        return;
    }
    char temp;
    while (begin < end) {
        temp = str[begin];
        str[begin] = str[end];
        str[end] = temp;
        begin++;
        end--;
    }
}

string LeftRotateString(string str, int n) {
    if (str.empty() || str == " " || n >= str.length()) {
        return str;
    }
    string res = str;
    Reverse(res, 0, res.length() - 1);
    int k = res.length() - n;
    Reverse(res, 0, k - 1);
    Reverse(res, k, res.length() - 1);
    return res;
}

int main() {
    string str = LeftRotateString("   a", 1);
    cout << str << endl;
    return 0;
}